<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        body {
            margin: 0;
        }

        canvas {
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body>
    <script>
        function gethttp(url) {
            var xhr = new XMLHttpRequest();
            xhr.addEventListener("readystatechange",
                function () {
                    if (this.readyState === 4) { }
                });
            xhr.open("GET", url, false);
            xhr.send();
            return xhr.responseText;
        }
        // var locs = window.Date.global("LOC").split(",");
        var locs0 = 34.767782;
        var locs1 = 113.593853;
        var regeoUrl = "http://autodev.openspeech.cn/csp/api/v2.1/weather?openId=aiuicus&latitude=" + locs0 + "&longitude=" + locs1 + "&startTime=&needMoreData=true&weatherIndex=xc&clientType=0&pageNo=1&pageSize=7&projectOpenId=5d524e87&sign=1247578872b2a6cbde6f8fb7123bd2513429b783"
        // var result = JSON.parse(gethttp(regeoUrl));
        var ajax = new XMLHttpRequest();
        ajax.open('get', regeoUrl);
        //步骤三:发送请求
        ajax.send();
        //步骤四:注册事件 onreadystatechange 状态改变就会调用
        ajax.onreadystatechange = function () {
            if (ajax.readyState == 4 && ajax.status == 200) {
                //步骤五 如果能够进到这个判断 说明 数据 完美的回来了,并且请求的页面是存在的
                console.log(ajax.responseText);//输入相应的内容
            }else{
                console.log('失败', ajax.responseText);//输入相应的内容
            }
        }

        var voice_text = "今天" + result.data.list[0].city + "，天气" + result.data.list[0].weather + "，温度" + result.data.list[0].temp + "度，空气质量" + result.data.list[0].airQuality + "，" + result.data.list[0].weatherIndex[0].desp;

        console.log(result);
    </script>
</body>

</html>